package cn.com.homeyoda.aimate.aihealth.ui.health.adapter;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.ArrayList;
import java.util.List;

import cn.com.homeyoda.aimate.aihealth.R;
import cn.com.homeyoda.aimate.aihealth.bean.ChronicDiseaseItemBean;
import cn.com.homeyoda.aimate.aihealth.bean.ChronicDiseaseSelectBean;

public class DiseaseSelectAdapter extends BaseQuickAdapter<ChronicDiseaseItemBean.DataBean, BaseViewHolder> {

    public DiseaseSelectAdapter(List<ChronicDiseaseItemBean.DataBean> data, Context context) {
        super(R.layout.item_disease_select, data);
        mContext = context;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, ChronicDiseaseItemBean.DataBean item) {
        helper.setText(R.id.tv_text, item.getName());
        if (item.isSelect()) {
            helper.itemView.setBackgroundResource(R.drawable.bg_rectangle_select);
            helper.setTextColor(R.id.tv_text, mContext.getResources().getColor(R.color.white));
            switch (item.getName()) {
                case "高血压":
                    helper.setBackgroundRes(R.id.iv_icon, R.mipmap.icon_gaoxueya);
                    break;
                case "冠心病":
                    helper.setBackgroundRes(R.id.iv_icon, R.mipmap.icon_guanxinbing);
                    break;
                case "糖尿病":
                    helper.setBackgroundRes(R.id.iv_icon, R.mipmap.icon_tangniaobing);
                    break;
            }
        } else {
            helper.itemView.setBackgroundResource(R.drawable.bg_rectangle_unselect);
            helper.setTextColor(R.id.tv_text, mContext.getResources().getColor(R.color.black_80));

            switch (item.getName()) {
                case "高血压":
                    helper.setBackgroundRes(R.id.iv_icon, R.mipmap.icon_gaoxueya);
                    break;
                case "冠心病":
                    helper.setBackgroundRes(R.id.iv_icon, R.mipmap.icon_guanxinbing);
                    break;
                case "糖尿病":
                    helper.setBackgroundRes(R.id.iv_icon, R.mipmap.icon_tangniaobing);
                    break;
            }
        }

    }

}